<template>
  <div>
    <el-table v-loading="loading" :data="dataSource" @row-click="handleRowClick" border :height="autoHeight">
      <el-table-column prop="docName" label="文档名称" align="center" width="350">
        <template slot="header" slot-scope="scope">
          <div>{{ scope.column.label }}</div>
          <el-input v-model="filterModel[scope.column.property]" :placeholder="scope.column.label + '过滤'" clearable @change="filterChange(scope.column.property)"></el-input>
        </template>
      </el-table-column>
      <el-table-column prop="createAt" label="签名日期" align="center" width="150"> </el-table-column>
<!--      <el-table-column prop="signDocDigest" label="签名前摘要" align="center"> </el-table-column>-->
<!--      <el-table-column prop="recordDigest" label="签名后摘要" align="center"></el-table-column>-->
      <el-table-column prop="signConf" label="签名配置" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column label="操作" align="center" width="70px">
        <div slot-scope="scope">
          <el-button type="success" icon="el-icon-view" circle @click="viewDoc(scope.row, scope.$index)" title="预览"></el-button>
        </div>
      </el-table-column>
    </el-table>
    <div class="lab-table-page">
      <div style="display: inline-flex">
        <el-pagination
            :disabled="loading"
            :current-page="pageInfo.page"
            :page-sizes="[5, 10, 15, 20, 50, 100]"
            :page-size="pageInfo.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="pageInfo.total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
        />
        <el-button-group style="padding: 2px 5px">
          <el-button icon="el-icon-refresh" title="刷新" :disabled="loading" @click="loadSource([])" />
        </el-button-group>
      </div>
    </div>

    <el-dialog :visible.sync="visible" title="菜单信息">
      <el-form label-position="right" label-width="80px">
        <el-form-item label="名称" required>
          <el-input v-model="entityInfo.roleName" placeholder="角色名称"/>
        </el-form-item>
        <el-form-item label="编码">
          <el-input v-model="entityInfo.roleCode" placeholder="角色编码"/>
        </el-form-item>
        <el-form-item label="级别">
          <el-input-number v-model="entityInfo.roleLevel" controls-position="right" placeholder="角色级别" style="width: 100%"/>
        </el-form-item>
        <el-form-item label="能力">
          <el-input type="textarea" :rows="4"  v-model="entityInfo.roleAbility" placeholder="角色能力"/>
        </el-form-item>
        <el-form-item label="状态">
          <el-radio-group v-model="entityInfo.dataState">
            <el-radio :label="-1">禁用</el-radio>
            <el-radio :label="0">正常</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-circle-check" type="success" @click="saveData(entityInfo)">{{ entityInfo.roleId ? '更新' : '保存' }}</el-button>
          <el-button icon="el-icon-circle-close" type="info" @click="visible = false">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import IdeaTable from "@/mixins/IdeaTable";

export default {
  name: "RoleTable",
  mixins: [IdeaTable],
  props: {
    select: {
      type: Boolean,
      default: false
    }
  },
  computed:{
    autoHeight() {
      return `calc(100vh - 135px)`
    },
  },
  created() {
    this.queryUrl = '/signRecord/queryPage'
    this.saveUrl = '/signRecord/save'
    this.removeUrl = '/signRecord/delete/'
    this.rowKey = 'recordId'
    this.pageInfo.sorts.push({field:'createAt',asc:false})
    this.loadSource()
  },
  methods: {
    viewDoc(row) {
      const url = this.$Util.mergeUrl(process.env.VUE_APP_BASE_API, '/signRecord/preview/' + row.recordId + '?access_token=' + this.$AuthStorage.getAccessToken())
      window.open(url)
    }
  }
}
</script>

<style scoped>

</style>
